package com.ruoyi.yl.controller;


import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.domain.SysNotice;
import com.ruoyi.common.domain.dto.MerchantActivityDTO;
import com.ruoyi.common.domain.query.MerchantActivityQuery;
import com.ruoyi.yl.service.IActivityService;
import com.ruoyi.yl.service.ISysNoticeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 首页接口
 *
 * @author ruoyi
 */
@Slf4j
@RestController
@RequestMapping("/index")
public class IndexController extends BaseController {





    @Resource
    private ISysNoticeService noticeService;

    @Resource
    private IActivityService activityService;

    /**
     * 查询公告Query announcement
     *
     * @return AjaxResult
     */
    @PostMapping("/get/announcement")
    public TableDataInfo getAnnouncement(@RequestBody SysNotice notice) {
        startPage();
        //2 为公告类型
        return getDataTable(noticeService.selectNoticeListByType("2"));
    }


    /**
     * 查询活动信息
     *
     * @return AjaxResult
     */
    @PostMapping("/get/activity")
    public TableDataInfo getActivity(@RequestBody MerchantActivityQuery query) {

        startPage();
        List<MerchantActivityDTO> list = activityService.getNearbyMerchantActivity(query);
        return getDataTable(list);
    }


}
